package com.dommettj.rawfix.message;

public enum MessageType {

    LOGON("A"),
    HEARTBEAT("0"),
    TEST_REQUEST("1"),
    RESEND("2"),
    REJECT("3"),
    SEQUENCE_RESET("4"),
    LOGOFF("5"),
    EXECUTION_REPORT("8"),
    ORDER_CANCEL_REJECT("9"),
    SECURITY_DEFINITION_REQUEST("c"),
    SECURITY_DEFINITION("d"),
    SECURITY_STATUS_REQUEST("e"),
    SECURITY_STATUS("f"),
    MASS_QUOTE("i"),
    TRADE_CAPTURE_REPORT_REQUEST("AD"),
    TRADE_CAPTURE_REPORT("AE"),
    ORDER_SINGLE("D"),
    ORDER_CANCEL("F"),
    ORDER_CANCEL_REPLACE("G"),
    MARKET_DATA_REQUEST("V"),
    MARKET_DATA_SNAPSHOT_REFRESH("W"),
    MARKET_DATA_INCREMENTAL_REFRESH("X");

    private String type;

    private MessageType(final String type) {
        this.type = type;
    }

    public static MessageType fromTypeString(final String type) {
        for(MessageType t : MessageType.values()) {
            if(t.type.equals(type)) {
                return t;
            }
        }
        return null;
    }

    public String getTypeString() {
        return type;
    }
}
